using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using CosyTrade.Core;

namespace CosyTrade.Network.Portal
{
    [Addin("NetworkPortal")]
    public class NetworkPortal : AddinBase
    {
        private TcpChannel tcpChannel;
        protected override void OnInitialize()
        {
            int port = int.Parse(ConfigNode["Port"].InnerText);
            tcpChannel = new TcpChannel(port);
            ChannelServices.RegisterChannel(tcpChannel, false);
            MethodInvoke.CurrentAddinManager = CurrentAddinManager;
            RemotingConfiguration.RegisterActivatedServiceType(typeof(MethodInvoke));
        }

        public override void Terminate()
        {
            ChannelServices.UnregisterChannel(tcpChannel);
        }

    }
}